<template>
  <u-popup v-model="show" :mask-close-able="flase" mode="center" width="96%" height="1050rpx">
    <view class="popup">
      <text class="title">抽奖记录</text>
      <view class="popupScroll">
        <view class="subtitle">我的奖品</view>
        <u-table font-size="24" v-if="prizeMines.length > 0">
          <u-tr>
            <u-th>奖品等级</u-th>
            <u-th>奖品</u-th>
            <u-th>操作</u-th>
          </u-tr>
          <u-tr v-for="(item, index) in prizeMines" :key="index">
            <u-td>{{ item.prizeName }}</u-td>
            <u-td>
              <u-td v-for="obj in item.objs" :key="obj.id">{{ obj.prizeDetail }}</u-td>
            </u-td>
            <u-td>
              <u-td v-for="obj in item.objs" :key="obj.id">
                <view @click.stop="clickTrAction(obj)" style="color: blue">{{ obj.action == 1 ? '去使用' : '' }}</view>
              </u-td>
            </u-td>
          </u-tr>
        </u-table>
        <view v-else class="tipText">暂无奖品记录</view>
        <view class="tipText">注：京东礼品卡和新春红包将由工作人员与您联系并发放。</view>
        <view class="subtitle">抽奖公示</view>
        <view class="tipText">关注“一览职业”公众号，查看抽奖信息。</view>
        <!-- <u-table font-size="24">
          <u-tr>
            <u-th>开奖日期</u-th>
            <u-th>公示链接</u-th>
          </u-tr>
          <u-tr v-for="(item, index) in prizeWheels" :key="index">
            <u-td>{{ item.lottery_date }}</u-td>
            <u-td>
              <view v-if="item.link.length > 0" @click.stop="clickLineAction(item)" style="color: blue">去查看</view>
              <view v-else>待开奖</view>
            </u-td>
          </u-tr>
        </u-table> -->
      </view>
      <u-button class="popupBtn" type="primary" @click="handleClick">确定</u-button>
    </view>
  </u-popup>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    prizeMines: {
      type: Array,
      default: [],
    },
    prizeWheels: {
      type: Array,
      default: [],
    },
  },

  data() {
    return {};
  },

  methods: {
    handleClick() {
      this.$emit("didClick");
    },

    clickTrAction(item) {
      console.log("去使用----", item);
      let index = item.id;
      if (index == 1 || index == 3 || index == 5 || index == 8) {
        // 进入职途页面
        uni.navigateTo({
          url: "/pagesSub/userCenter/careerPathV2/index?form=zphActivity",
        });
      } else if (index == 6 || index == 9) {
        // 招聘会详情
        uni.navigateTo({
          url: "/pagesSub/careerGrow/zph/detail?type=ai&activityId=7681705653745728",
        });
      }
    },

    // 跳转公众号文章
    clickLineAction(item) {
      console.log("去查看----", item);
      return;

      if (!item.link) {
        uni.showToast({
          title: "链接有误",
          icon: "none",
        });
        return;
      }
      let urlObj = new URL(item.link);
      let __biz = urlObj.searchParams.get("__biz");
      let mid = urlObj.searchParams.get("mid");
      let idx = urlObj.searchParams.get("idx");
      let sn = urlObj.searchParams.get("sn");
      uni.navigateToMiniProgram({
        appId: "wxcbfa127f857c2790",
        path:
          "pages/xxx/xxx?__biz=" +
          __biz +
          "&mid=" +
          mid +
          "&idx=" +
          idx +
          "&sn=" +
          sn,
        extraData: {
          // 需要传递给目标小程序的数据，可选
          // ...
        },
        envVersion: "release", // 要打开的小程序版本, develop（开发版），trial（体验版），release（正式版）
        success(res) {
          console.log("----打开成功的回调函数", res);
        },
        fail(err) {
          console.log("----打开失败的回调函数", err);
          uni.showToast({
            title: "打开失败",
            icon: "error",
          });
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.popup {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  height: 100%;

  .popupScroll {
    overflow: auto;
    padding-bottom: 180rpx;
    display: flex;
    flex-direction: column;
    height: 840rpx;
    width: 95%;
  }

  .title {
    font-size: 40rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #454b5b;
    margin-top: 70rpx;
    margin-bottom: 50rpx;
  }
  .subtitle {
    font-size: 30rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: #454b5b;
    margin-bottom: 20rpx;
  }

  .table {
    margin: 43rpx 0;
    width: 90%;
  }
  .tipText {
    margin: 10rpx 35rpx;
    color: #b3b2b2;
    font-size: 24rpx;
    margin-bottom: 50rpx;
  }

  .inputVuew {
    width: 90%;
    .inputTip {
      color: #b3b2b2;
      font-size: 24rpx;
      margin-bottom: 20rpx;
    }
  }

  .popupBtn {
    position: absolute;
    bottom: 40rpx;
    left: 52rpx;
    right: 52rpx;
  }
}
</style>
